﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace olierFrm.WebFormDev.Cookie
{
    public class CTheme
    {
        public const string CookieName = "CookieTheme";
        public const int CookieDays = 14;
        public static int ThemeIndex
        {
            get
            {
                if (HttpContext.Current.Request.Cookies[CookieName] == null) return 0;
                return Convert.ToInt32(HttpContext.Current.Request.Cookies[CookieName].Values["ThemeIndex"]);
            }
            set
            {
                if (HttpContext.Current.Response.Cookies[CookieName].Values["ThemeIndex"] == null)
                    HttpContext.Current.Response.Cookies[CookieName].Values.Add("ThemeIndex", value.ToString());
                HttpContext.Current.Response.Cookies[CookieName].Values["ThemeIndex"] = value.ToString();
                HttpContext.Current.Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(14);
            }
        }
        public static string Theme
        {
            get
            {
                if (HttpContext.Current.Request.Cookies[CookieName] == null) return null;
                return HttpContext.Current.Request.Cookies[CookieName].Values["Theme"];
            }
            set
            {
                if (HttpContext.Current.Response.Cookies[CookieName].Values["Theme"] == null)
                    HttpContext.Current.Response.Cookies[CookieName].Values.Add("Theme", value);
                HttpContext.Current.Response.Cookies[CookieName].Values["Theme"] = value;
                HttpContext.Current.Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(14);
            }
        }
    }
}
